

import 'package:bookshelf/main.dart';

String? analysisBookRule(String block){
  String rule = settingEntity.analysisBook??'xy';
  String? result = '';
  if(rule == 'xy'){
    result = xyRule(block);
  }
  if(rule == 'py'){
    result = pyRule(block);
  }
  return result;
}

String? xyRule(String block){
  int? len = int.tryParse(block.substring(0,2));
  if(len != null && block.length>len+2){
    var no = block.substring(2,len+2);
    return no;
  }
  return null;
}

String? pyRule(String block){
  var str = block.substring(2,4);
  if(str == '07'){
    var no = block.substring(4,17);
    return no;
  }else{
    str = block.substring(4,6);
    if(str == '07'){
      var no = block.substring(6,19);
      return no;
    }else{
      return null;
    }
  }
}
